There is no denying that 2020 was an eventful year. From the COVID-19 pandemic, to the revival of the Black Lives Matter (BLM) movement and the Presidential election between Joe Biden and Donald Trump, the people of the United States were consistently on edge. While the whole world was stuck at home, mis-information ran wild across the internet and conspiracy theories made their way into the mainstream. The violent rhetoric coming from the White House empowered far right individuals and groups to comit arguably the worst act of domestic terrorism since the country’s inception in what we now know as the January 6th Capitol Insurrection.
Academics and journalists alike have studied and reported on the significant role that social media played in this context. However, little attention has been put toward the spatial dimension of the use of social media surrounding it. This project aims to close that gap by exploring the spatial distribution of hashtag use in Tweets made across the United States during the peak of the BLM movement in the summer of 2020.
We choose to look at Black Lives Matter because of it’s rise to prominence as a social movement, following the murder of George Floyd. We tracked the following three hashtags on key dates of the summer of 2020 (May 26th - 31st) and spring of 2021 (March 8th and 28th): #blacklivesmatter, #blm, #icantbreathe.
The obective of this part of the project was to understand the spatial distribution of people actively tweeting about Black Lives Matter during it’s peak online. To this end, we used the Twitter location data of the users and not the Tweets themselves to create Choropleth maps of the number of Tweets sent by state as well as Kernel Density Maps based on those tweets that did contain latitude and longitude.
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v tibble 3.1.1 v dplyr 1.0.7
## v tidyr 1.1.4 v stringr 1.4.0
## v readr 2.0.2 v forcats 0.5.1
## v purrr 0.3.4
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x lubridate::as.difftime() masks base::as.difftime()
## x readr::col_factor() masks scales::col_factor()
## x lubridate::date() masks base::date()
## x purrr::discard() masks scales::discard()
## x dplyr::filter() masks stats::filter()
## x lubridate::intersect() masks base::intersect()
## x dplyr::lag() masks stats::lag()
## x lubridate::setdiff() masks base::setdiff()
## x lubridate::union() masks base::union()
## Registering fonts with R
After selecting and visualizing the most important dates for the Black Lives Matter protest, we used Python to create a web scrapper to scrape all the tweets from those days and download them onto our computer. The specific scrapper we used for this step is called {r}snscrape. It was only able to extract the location from the Twitter User’s bio, as they had manually input it. Getting the coordinates from where the tweet was sent would involve paying money to use Twitter’s expensive API. For this reason, we had to do extensive data cleaning. Additionally, though we have done our best to ensure the accuracy of the data, one potential weakness of this dataset is that it is vulnerable to people who are joking or lying or inaccurately representing their location online.
To clean our data, we both used manual cleaning and Python. The manual cleaning was to augment and verify the Python scripts we used to clean the data. The Python scripts themselves can be found in this repo as well. To manually clean the data, we looked at each spreadsheet to eliminate false, fake, or otherwise inappropriate entries. This was to prepare the data for the geocoding codes to pull the lat and long values from cities and states. After that Python script was run, we did a final manual cleaning to ensure the lat/long values were correctly lined up.
Next, we cleaned our data, imported it into R. In R, we reshaped our data and then used it to create Kernel Density Maps based on the lat/long coordinates of the Twitter User and Choropleth maps based on the number of tweets per state.
Our data preprocessing was extensive. In the Python files included in this repo, there are codes for the multiple runs of cleaning that were required. In addition to using these Python scripts to eliminate false entries and format the other location entries into a format a geocoding program could understand, we had to manually go through all of the spreadsheets to verify the accuracy and success of the Python cleaning scripts.
#Choropleth Maps Data Processing (SM) For the Choropleth maps, we read in all our excel files and then reshaped the data so that a count field was calculated representing the number of tweets in each state. We also added a field to contain the hover text in our final, interactive choropleth state map. Finally, we joined all the tables together into one and changed the date field to a POSIXct object so it would be read correctly by Plotly, the mapping library we would be using to create our chloropleth maps.
#load libraries
library(tidyverse)
library(readxl)
library(ggplot2)
library(maps)
##
## Attaching package: 'maps'
## The following object is masked from 'package:purrr':
##
## map
library(mapdata)
library(tmaptools)
## Registered S3 methods overwritten by 'stars':
## method from
## st_bbox.SpatRaster sf
## st_crs.SpatRaster sf
library(patchwork)
library(ggtext)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(readr)
library(lubridate)
##reading the excels and shaping the data
#blacklivesmatter
blacklivesmatter_030821 <- read_excel("Data\\BLM\\blacklivesmatter_030821.xlsx")
blacklivesmatter_030821_points <- blacklivesmatter_030821 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
blacklivesmatter_032821 <- read_excel("Data\\BLM\\blacklivesmatter_032821.xlsx")
blacklivesmatter_032821_points <- blacklivesmatter_032821 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
blacklivesmatter_052620 <- read_excel("Data\\BLM\\blacklivesmatter_052620.xlsx")
blacklivesmatter_052620_points <- blacklivesmatter_052620 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
blacklivesmatter_052720 <- read_excel("Data\\BLM\\blacklivesmatter_052720.xlsx")
blacklivesmatter_052720_points <- blacklivesmatter_052720 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
blacklivesmatter_052920 <- read_excel("Data\\BLM\\blacklivesmatter_052920.xlsx")
blacklivesmatter_052920_points <- blacklivesmatter_052920 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
blacklivesmatter_053120 <- read_excel("Data\\BLM\\blacklivesmatter_053120.xlsx")
blacklivesmatter_053120_points <- blacklivesmatter_053120 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
#blm
blm_030821 <- read_excel("Data\\BLM\\blm_030821.xlsx")
blm_030821_points <- blm_030821 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
blm_032821 <- read_excel("Data\\BLM\\blm_032821.xlsx")
blm_032821_points <- blm_032821 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
blm_052620 <- read_excel("Data\\BLM\\blm_052620.xlsx")
blm_052620_points <- blm_052620 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
blm_052720 <- read_excel("Data\\BLM\\blm_052720.xlsx")
blm_052720_points <- blm_052720 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
blm_052820 <- read_excel("Data\\BLM\\blm_052820.xlsx")
blm_052820_points <- blm_052820 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
blm_052920 <- read_excel("Data\\BLM\\blm_052920.xlsx")
blm_052920_points <- blm_052920 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
blm_053120 <- read_excel("Data\\BLM\\blm_053120.xlsx")
blm_053120_points <- blm_053120 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
#icantbreath
icantbreathe_032821 <- read_excel("Data\\BLM\\icantbreathe_032821.xlsx")
icantbreathe_032821_points <- icantbreathe_032821 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
icantbreathe_052620 <- read_excel("Data\\BLM\\icantbreathe_052620.xlsx")
icantbreathe_052620_points <- icantbreathe_052620 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
icantbreathe_052720 <- read_excel("Data\\BLM\\icantbreathe_052720.xlsx")
icantbreathe_052720_points <- icantbreathe_052720 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
icantbreathe_052820 <- read_excel("Data\\BLM\\icantbreathe_052820.xlsx")
icantbreathe_052820_points <- icantbreathe_052820 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
icantbreathe_052920 <- read_excel("Data\\BLM\\icantbreathe_052920.xlsx")
icantbreathe_052920_points <- icantbreathe_052920 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
icantbreathe_053120 <- read_excel("Data\\BLM\\icantbreathe_053120.xlsx")
icantbreathe_053120_points <- icantbreathe_053120 %>%
mutate(region = (state.name[match(STATE,state.abb)]), date = as.Date(DATE)) %>%
add_count(STATE) %>%
mutate(value = n, date_col = floor_date(date, "day")) %>%
mutate(hover = paste0(region, "\n", value , " tweet(s)")) %>%
distinct(region, value, hover, date_col, STATE) %>%
data.frame()
##joining the date
#icantbreate
icantbreathe_join <- icantbreathe_053120_points %>%
full_join(icantbreathe_052920_points, by.x=region, by.y=region) %>%
full_join(icantbreathe_052820_points, by.x=region, by.y=region) %>%
full_join(icantbreathe_052720_points, by.x=region, by.y=region) %>%
full_join(icantbreathe_052620_points, by.x=region, by.y=region) %>%
full_join(icantbreathe_032821_points, by.x=region, by.y=region) %>%
mutate(date_final = paste0(as.POSIXct(date_col)))
## Joining, by = c("STATE", "region", "value", "date_col", "hover")
## Joining, by = c("STATE", "region", "value", "date_col", "hover")
## Joining, by = c("STATE", "region", "value", "date_col", "hover")
## Joining, by = c("STATE", "region", "value", "date_col", "hover")
## Joining, by = c("STATE", "region", "value", "date_col", "hover")
#blacklivesmatter
blacklivesmatter_join <- blacklivesmatter_052920_points %>%
full_join(blacklivesmatter_030821_points, by.x=region, by.y=region) %>%
full_join(blacklivesmatter_032821_points, by.x=region, by.y=region) %>%
full_join(blacklivesmatter_052620_points, by.x=region, by.y=region) %>%
full_join(blacklivesmatter_052720_points, by.x=region, by.y=region) %>%
full_join(blacklivesmatter_053120_points, by.x=region, by.y=region) %>%
mutate(date_final = paste0(as.POSIXct(date_col)))
## Joining, by = c("STATE", "region", "value", "date_col", "hover")
## Joining, by = c("STATE", "region", "value", "date_col", "hover")
## Joining, by = c("STATE", "region", "value", "date_col", "hover")
## Joining, by = c("STATE", "region", "value", "date_col", "hover")
## Joining, by = c("STATE", "region", "value", "date_col", "hover")
#blm
blm_join <- blm_053120_points %>%
full_join(blm_052820_points, by.x=region, by.y=region) %>%
full_join(blm_052920_points, by.x=region, by.y=region) %>%
full_join(blm_052620_points, by.x=region, by.y=region) %>%
full_join(blm_030821_points, by.x=region, by.y=region) %>%
full_join(blm_032821_points, by.x=region, by.y=region) %>%
full_join(blm_052720_points, by.x=region, by.y=region) %>%
mutate(date_final = paste0(as.POSIXct(date_col)))
## Joining, by = c("STATE", "region", "value", "date_col", "hover")
## Joining, by = c("STATE", "region", "value", "date_col", "hover")
## Joining, by = c("STATE", "region", "value", "date_col", "hover")
## Joining, by = c("STATE", "region", "value", "date_col", "hover")
## Joining, by = c("STATE", "region", "value", "date_col", "hover")
## Joining, by = c("STATE", "region", "value", "date_col", "hover")
#Kernel Density Data Processing Methods (VC) We read in the data, then subset to not include Alaska and Hawaii for aesthetic and spacing purposes in the ggplot2 multiplots we will be making later in this package. After eliminating Alaska and Hawaii, we created kernel density maps for each spreadsheet in ggplot.
library(tidyverse)
library(readxl)
library(ggplot2)
library(maps)
library(mapdata)
library(tmaptools)
library(patchwork)
library(ggtext)
windowsFonts(Georgia = windowsFont("TT Georgia"))
# Read #blacklivesmatter data
blacklivesmatter_030821 <- read_excel("Data\\BLM\\blacklivesmatter_030821.xlsx")
blacklivesmatter_032821 <- read_excel("Data\\BLM\\blacklivesmatter_032821.xlsx")
blacklivesmatter_052620 <- read_excel("Data\\BLM\\blacklivesmatter_052620.xlsx")
blacklivesmatter_052720 <- read_excel("Data\\BLM\\blacklivesmatter_052720.xlsx")
blacklivesmatter_052920 <- read_excel("Data\\BLM\\blacklivesmatter_052920.xlsx")
blacklivesmatter_053120 <- read_excel("Data\\BLM\\blacklivesmatter_053120.xlsx")
# Read #blm data
blm_030821 <- read_excel("Data\\BLM\\blm_030821.xlsx")
blm_032821 <- read_excel("Data\\BLM\\blm_032821.xlsx")
blm_052620 <- read_excel("Data\\BLM\\blm_052620.xlsx")
blm_052720 <- read_excel("Data\\BLM\\blm_052720.xlsx")
blm_052820 <- read_excel("Data\\BLM\\blm_052820.xlsx")
blm_052920 <- read_excel("Data\\BLM\\blm_052920.xlsx")
blm_053120 <- read_excel("Data\\BLM\\blm_053120.xlsx")
# Read #icantbreathe data
icantbreathe_032821 <- read_excel("Data\\BLM\\icantbreathe_032821.xlsx")
icantbreathe_052620 <- read_excel("Data\\BLM\\icantbreathe_052620.xlsx")
icantbreathe_052720 <- read_excel("Data\\BLM\\icantbreathe_052720.xlsx")
icantbreathe_052820 <- read_excel("Data\\BLM\\icantbreathe_052820.xlsx")
icantbreathe_052920 <- read_excel("Data\\BLM\\icantbreathe_052920.xlsx")
icantbreathe_053120 <- read_excel("Data\\BLM\\icantbreathe_053120.xlsx")
# Subset cities in the continental US only
blacklivesmatter_030821_points <- subset(blacklivesmatter_030821, LAT != "" &
STATE != "HI" & STATE != "AK")
blacklivesmatter_032821_points <- subset(blacklivesmatter_032821, LAT != "" &
STATE != "HI" & STATE != "AK")
blacklivesmatter_052620_points <- subset(blacklivesmatter_052620, LAT != "" &
STATE != "HI" & STATE != "AK")
blacklivesmatter_052720_points <- subset(blacklivesmatter_052720, LAT != "" &
STATE != "HI" & STATE != "AK")
blacklivesmatter_052920_points <- subset(blacklivesmatter_052920, LAT != "" &
STATE != "HI" & STATE != "AK")
blacklivesmatter_053120_points <- subset(blacklivesmatter_053120, LAT != "" &
STATE != "HI" & STATE != "AK")
# Subset cities in the continental US only
blm_030821_points <- subset(blm_030821, LAT != "" & STATE != "HI" &
STATE != "AK")
blm_032821_points <- subset(blm_032821, LAT != "" & STATE != "HI" &
STATE != "AK")
blm_052620_points <- subset(blm_052620, LAT != "" & STATE != "HI" &
STATE != "AK")
blm_052720_points <- subset(blm_052720, LAT != "" & STATE != "HI" &
STATE != "AK")
blm_052820_points <- subset(blm_052820, LAT != "" & STATE != "HI" &
STATE != "AK")
blm_052920_points <- subset(blm_052920, LAT != "" & STATE != "HI" &
STATE != "AK")
blm_053120_points <- subset(blm_053120, LAT != "" & STATE != "HI" &
STATE != "AK")
# Subset cities in the continental US only
icantbreathe_032821_points <- subset(icantbreathe_032821, LAT != "" &
STATE != "HI" & STATE != "AK")
icantbreathe_052620_points <- subset(icantbreathe_052620, LAT != "" &
STATE != "HI" & STATE != "AK")
icantbreathe_052720_points <- subset(icantbreathe_052720, LAT != "" &
STATE != "HI" & STATE != "AK")
icantbreathe_052820_points <- subset(icantbreathe_052820, LAT != "" &
STATE != "HI" & STATE != "AK")
icantbreathe_052920_points <- subset(icantbreathe_052920, LAT != "" &
STATE != "HI" & STATE != "AK")
icantbreathe_053120_points <- subset(icantbreathe_053120, LAT != "" &
STATE != "HI" & STATE != "AK")
# Define a variable for the state map
state <- map_data("state")
# Point density map for #blacklivesmatter
# March 8th, 2021
density_lives_030821 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = blacklivesmatter_030821_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = blacklivesmatter_030821_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# March 28th, 2021
density_lives_032821 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = blacklivesmatter_032821_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = blacklivesmatter_032821_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# May 26th, 2020
density_lives_052620 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = blacklivesmatter_052620_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = blacklivesmatter_052620_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# May 27th, 2020
density_lives_052720 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = blacklivesmatter_052720_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = blacklivesmatter_052720_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# May 29th, 2020
density_lives_052920 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = blacklivesmatter_052920_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = blacklivesmatter_052920_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# May 31st, 2020
density_lives_053120 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = blacklivesmatter_053120_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = blacklivesmatter_053120_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# Point density map for #blm
# March 8th, 2021
density_blm_030821 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = blm_030821_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = blm_030821_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# March 28th, 2021
density_blm_032821 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = blm_032821_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = blm_032821_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# May 26th, 2020
density_blm_052620 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = blm_052620_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = blm_052620_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# May 27th, 2020
density_blm_052720 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = blm_052720_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = blm_052720_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# May 28th, 2020
density_blm_052820 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = blm_052820_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = blm_052820_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# May 29th, 2020
density_blm_052920 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = blm_052920_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = blm_052920_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# May 31st, 2020
density_blm_053120 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = blm_053120_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = blm_053120_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# Point density map for #icantbreathe
# March 28th, 2021
density_breathe_032821 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = icantbreathe_032821_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = icantbreathe_032821_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# May 26th, 2020
density_breathe_052620 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = icantbreathe_052620_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = icantbreathe_052620_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# May 27th, 2020
density_breathe_052720 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = icantbreathe_052720_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = icantbreathe_052720_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# May 28th, 2020
density_breathe_052820 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = icantbreathe_052820_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = icantbreathe_052820_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# May 29th, 2020
density_breathe_052920 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = icantbreathe_052920_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = icantbreathe_052920_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
# May 31st, 2020
density_breathe_053120 <- ggplot(data = state, aes(x = long, y = lat,
group = group)) +
geom_polygon(color = "black", fill = "white") +
theme(panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(), axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
geom_point(data = icantbreathe_053120_points, aes(x = LONG, y = LAT),
size = 2, shape = 20, colour = "darkred", inherit.aes = FALSE) +
geom_density2d_filled(data = icantbreathe_053120_points,
aes(x = LONG, y = LAT), alpha = 0.5,
inherit.aes = FALSE, show.legend = FALSE)
Our data resulted in six figures, consisting of 6-7 maps. The first three figures are Choropleth Maps done by State. Each Choropleth figure possess a slider bar on the bottom that users can manipulate to switch between years. Users can also press the play button on the bottom left in order to watch the spatial distribution of tweets through time.
The next three figures depict Kernel Density Maps. Each figure shows a Kernel Density Map for all six dates. There is a figure generated for each hashtag.
Each code chunk will create a map where users can move through all available dates for a different hashtag.
##establishing consistent styling for maps
fontStyle = list(
family = "TT Georgia",
size = 15,
color = "black"
)
label = list(
bgcolor = "#FFFFFF",
bordercolor = "transparent",
font = fontStyle
)
#icantbreathe hashtag map
icantbreathe_map = plot_geo(icantbreathe_join, locationmode = 'USA-states') %>%
add_trace(locations = ~STATE,
z = ~value,
color = ~value,
colorscale="Hot",
zmin=0,
zmax=max(icantbreathe_join$value),
text = ~hover,
hoverinfo = 'text',
frame = ~date_final) %>%
layout(geo = list(scope = "usa"),
font = list(family = "TT Georgia")) %>%
style(hoverlabel = label)
#displaying the map
icantbreathe_map
blm_map = plot_geo(blm_join, locationmode = 'USA-states') %>%
add_trace(locations = ~STATE,
z = ~value,
color = ~value,
colorscale="Hot",
zmin=0,
zmax=max(blm_join$value),
text = ~hover,
hoverinfo = 'text',
frame = ~date_final) %>%
layout(geo = list(scope = "usa"),
font = list(family = "TT Georgia")) %>%
style(hoverlabel = label)
#displaying the map
blm_map
blacklivesmatter_map = plot_geo(blacklivesmatter_join, locationmode = 'USA-states') %>%
add_trace(locations = ~STATE,
z = ~value,
color = ~value,
colorscale="Hot",
zmin=0,
zmax=max(blacklivesmatter_join$value),
text = ~hover,
hoverinfo = 'text',
frame = ~date_final) %>%
layout(geo = list(scope = "usa"),
font = list(family = "TT Georgia")) %>%
style(hoverlabel = label)
#displaying the map
blacklivesmatter_map
Each code chunk will create a different multiplot map displaying the kernel density for each hashtag. The first code chunk will establish the annotation for all three of the multiplot maps.
## establishing the annotations for each figures
# Define the figure's annotation
lives_legend <- plot_annotation(
caption = "(A) May 26th, 2020. (B) May 27th, 2020. (C) May 29th, 2020.
(D) May 31st, 2020. (E) March 8th, 2021. (F) March 28th, 2021.",
theme = theme(
plot.caption = element_textbox_simple(
size = 9,
box.colour = "black",
linetype = 1,
padding = unit(c(3, 3, 3, 3), "pt"),
r = unit(0, "pt")
)
)
)
# Define the figure's annotation
blm_legend <- plot_annotation(
caption = "(A) May 26th, 2020. (B) May 27th, 2020. (C) May 28th, 2020.
(D) May 29th, 2020. (E) May 31st, 2020. (F) March 8th, 2021.
(G) March 28th, 2021.",
theme = theme(
plot.caption = element_textbox_simple(
size = 9,
box.colour = "black",
linetype = 1,
padding = unit(c(3, 3, 3, 3), "pt"),
r = unit(0, "pt")
)
)
)
# Define the figure's annotation
breathe_legend <- plot_annotation(
caption = "(A) May 26th, 2020. (B) May 27th, 2020. (C) May 28th, 2020.
(D) May 29th, 2020. (E) May 31st, 2020. (F) March 28th, 2021",
theme = theme(
plot.caption = element_textbox_simple(
size = 9,
box.colour = "black",
linetype = 1,
padding = unit(c(3, 3, 3, 3), "pt"),
r = unit(0, "pt")
)
)
)
# Multiplot for #blacklivesmatter
multiplot_lives <-
density_lives_052620 +
density_lives_052720 +
density_lives_052920 +
density_lives_053120 +
density_lives_030821 +
density_lives_032821 +
lives_legend +
plot_layout(ncol = 3) +
plot_annotation(title = "Spatial Distribution of Tweets that included #blacklivesmatter",
tag_levels = "A") &
theme(plot.title = element_text(hjust = 0.5, face = "bold"),
plot.tag = element_text(size = 10, hjust = 0, vjust = -1),
plot.tag.position = c(0, 0.85),
text = element_text("Georgia"))
multiplot_lives
# Multiplot for #icantbreathe
multiplot_breathe <-
density_breathe_052620 +
density_breathe_052720 +
density_breathe_052820 +
density_breathe_052920 +
density_breathe_053120 +
density_breathe_032821 +
breathe_legend +
plot_layout(ncol = 3) +
plot_annotation(title = "Spatial Distribution of Tweets that included #icantbreathe",
tag_levels = "A") &
theme(plot.title = element_text(hjust = 0.5, face = "bold"),
plot.tag = element_text(size = 10, hjust = 0, vjust = -1),
plot.tag.position = c(0, 0.85),
text = element_text("Georgia"))
multiplot_breathe
## Warning: Removed 36 rows containing non-finite values (stat_density2d_filled).
## Warning: Removed 36 rows containing missing values (geom_point).
## Warning: Removed 22 rows containing non-finite values (stat_density2d_filled).
## Warning: Removed 22 rows containing missing values (geom_point).
# Multiplot for #blm
multiplot_blm <-
density_blm_052620 +
density_blm_052720 +
density_blm_052820 +
density_blm_052920 +
density_blm_053120 +
density_blm_030821 +
density_blm_032821 +
blm_legend +
plot_layout(ncol = 3) +
plot_annotation(title = "Spatial Distribution of Tweets that included #blm",
tag_levels = "A") &
theme(plot.title = element_text(hjust = 0.5, face = "bold"),
plot.tag = element_text(size = 10, hjust = 0, vjust = -1),
plot.tag.position = c(0, 0.85),
text = element_text("Georgia"))
multiplot_blm
Looking at the choropleth maps, there is a lot of variance between days that data was gathered for the black lives matter related hashtags, meaning there are many points where the map looks entirely black. Perhaps not using the same legend for all maps would make a more effective comparison when comparing such disaperate response rates.
The midwestern states appear to be more consistent tweeters, standing out on days where there are fewer overall tweets. There appears to be signficant variance across the country in states with high versus low Twitter activity.
Interestingly, in the density maps, similar to the election hashtags, there is a significant concentration of Twitter activity in the northeast, especially as opposed to populous areas like California. While California did show high density for a handful of maps across the three hashtags, it was far less so than the density of tweets on the East Coast or coming from East Coast states. Similarly, while the concentration in the north of the United States surprised me, it’s important to vote that George Floyd’s murder was in Minnisota, which could account for the weight of the entries from them and surrounding states.